package main

import (
	"fmt"
	"zinx/ziface"
	"zinx/znet"
)

type PingRouter struct {
	znet.BashRouter
}

// Test Handle
func (p *PingRouter) Handle(request ziface.IRequest) {
	fmt.Println("Call Router Handle")
	if _, err := request.GetConnection().GetTCPConnection().Write([]byte("ping..ping..ping..\n")); err != nil {
		fmt.Println("call back ping..ping..ping.. error")
	}
}

func main() {
	//1、创建一个server的句柄，使用Zinx的api
	s := znet.NewServer("[zinx V0.4]")

	//2、给当前Zinx框架添加一个自定义的router
	s.AddRouter(&PingRouter{})

	//3、启动server
	s.Serve()
}
